package cn.ggy.polo;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Scope(value = "singleton")
@Component
public class User {

    @Value("张三")
    private String name;

    public String getName() {
        return name;
    }

    public void show(){
        System.out.println("今天是个好日子");
    }

    @PostConstruct
    public void init(){
        System.out.println("user内的init方法!");
    }

    public User(){
        System.out.println("user的无参构造!");
    }

    @PreDestroy
    public void destroy(){
        //此方法得调用close方法才会执行
        System.out.println("user内的destroy方法");
    }
}
